Skip to content

dogfooding fixes: document StyleX build requirement for swizzled components#3475

Open
josephfarina wants to merge 1 commit into
mainfrom
navi/docs/swizzle-stylex-setup
Open

dogfooding fixes: document StyleX build requirement for swizzled components#3475
josephfarina wants to merge 1 commit into
mainfrom
navi/docs/swizzle-stylex-setup

Conversation

@josephfarina

Copy link
Copy Markdown
Contributor

What this fixes

astryx swizzle <Component> copies a component's raw StyleX source into your app. That source needs a build-time StyleX compiler to produce atomic CSS — but nothing in the CLI output or docs said so, and there was no framework-specific setup guidance. Result: a freshly swizzled component compiles but renders unstyled, with no error, and it's non-obvious why. Fixes #3373.

Changes

1. Post-copy CLI note (only when the swizzled source actually uses StyleX). The copy loop now detects @stylexjs/stylex usage and, for StyleX components, prints:

⚠ These components use StyleX and require a StyleX compiler in your build.
  Without one they render unstyled (no error). See setup per framework:
  npx astryx docs styling
  Next.js note: the StyleX Babel plugin disables SWC and breaks next/font —
  use an SWC-based StyleX transform instead (covered in the guide).

Components with no StyleX get no note (verified by a negative test). The --json payload also gains a usesStyleX boolean for machine consumers.

2. Docs: a "StyleX Build Setup" section in astryx docs styling. The issue noted that grepping the docs for babel, swc, next.config, compiler, transform, or plugin returned nothing. The new section covers:

  • Why swizzled components need a compiler (and that consuming the published package does not).
  • A per-bundler table (Webpack, Vite/Rollup, Babel, Next.js).
  • The Next.js App Router sharp edge: the StyleX Babel plugin disables SWC, which breaks next/font — so an SWC-based transform (e.g. the community @stylexswc/nextjs-plugin) is the working path, with a next.config example.
  • A pointer to the working reference app apps/example-nextjs-stylex in the repo.
  • The clarification that pure theming (defineTheme + astryx theme build) needs no StyleX compiler.

Why point at astryx docs styling rather than a wiki page

The issue mentioned astryx docs swizzle, but there is no swizzle docs topic, and no StyleX-setup wiki page exists yet. Rather than invent a URL, this puts the setup content in the existing styling doc (which the issue explicitly named as a gap) and points the CLI note there.

Verification

  • Ran astryx swizzle Button in the monorepo: the StyleX note prints with the Next.js caveat and the astryx docs styling pointer.
  • Ran astryx docs styling: the "StyleX Build Setup" section renders with the table, the Next.js note, and the next.config example.
  • New tests in swizzle.routing.test.mjs: a StyleX component reports usesStyleX: true and prints the note (asserting the compiler requirement, the unstyled symptom, the next/font caveat, and the docs pointer); a non-StyleX component reports usesStyleX: false and prints no note.
  • All existing swizzle tests (18 total across routing/path-safety/unit) pass; ESLint clean.

Swizzled components ship raw StyleX source that needs a build-time StyleX
compiler; without one they render unstyled with no error. The swizzle
command now prints a StyleX build-setup note after copying (with the
Next.js caveat that the StyleX Babel plugin disables SWC and breaks
next/font, so an SWC-based transform is required), and `astryx docs
styling` gains a StyleX Build Setup section covering per-bundler setup.

Fixes #3373
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 2, 2026
@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview, Comment Jul 2, 2026 10:54pm

Request Review

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.6KB 0B

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Swizzled components emit StyleX source, but no docs explain the required StyleX build/compiler setup (breaks silently; Next.js/SWC has no guidance)

1 participant